package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.PayCardLog;
import com.tbit.uqbike.object.pojo.dto.PayCardLogDownloadDTO;
import com.tbit.uqbike.object.pojo.dto.PayCardLogQueryDTO;
import com.tbit.uqbike.object.pojo.vo.PayCardLogSumVO;
import com.tbit.common.entity.view.PageResult;
import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.service.business.PayCardLogService;
import com.tbit.uqbike.webmanager.util.csv.annotations.AsyncDownload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 财务统计-购卡订单统计
 *
 * @Author:BUGTian
 * @DATE: 2022/11/12
 */
@RestController
@RequestMapping("/payCardLog")
public class PayCardLogController {

    @Autowired
    private PayCardLogService payCardLogService;


    /**
     * 分页查询购卡订单详情
     *
     * @param payCardLogQueryDTO
     * @return
     */
    @GetMapping("/queryPage")
    public Result<PageResult<PayCardLog>> queryPage(PayCardLogQueryDTO payCardLogQueryDTO) {
        payCardLogQueryDTO.assertParam();
        PageResult<PayCardLog> pageResult = payCardLogService.queryPage(payCardLogQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 购卡订单详情账单下载
     *
     * @param downloadDTO
     * @return
     */
    @AsyncDownload(defaultFileName = "购卡订单统计账单")
    @GetMapping("/download")
    public Result downloadPayCard(PayCardLogDownloadDTO downloadDTO) {
        String url = payCardLogService.downloadPayCard(downloadDTO);
        return Result.success(url);
    }

    /**
     * 购卡订单统计
     *
     * @param payCardLogQueryDTO
     * @return
     */
    @GetMapping("/sum")
    public Result<PayCardLogSumVO> sum(PayCardLogQueryDTO payCardLogQueryDTO) {
        payCardLogQueryDTO.assertParamIgnorePage();
        return Result.success(payCardLogService.sum(payCardLogQueryDTO));
    }

}
